<script >
	function addElement() {

	  var ni = document.getElementById('myDiv');

	  var numi = document.getElementById('theValue');

	  var num = (document.getElementById('theValue').value -1)+ 2;

	  numi.value = num;

	  var newdiv = document.createElement('div');

	  var divIdName = 'my'+num+'Div';

	  newdiv.setAttribute('id',divIdName);
	  newdiv.setAttribute('style','float:left; width:100%');

	  newdiv.innerHTML = '<p><input type="hidden" id="userfile'+num+'" name="sanpham_hinhanh'+num+'" value=""/><img src="" width="50" id="imgdef'+num+'" name="imgdef'+num+'" height="40" style="float:left; border:#CCC 1px solid" /><input type="button" name="button3" value="Up file đính kèm" onclick="JavaScript:window.open(\'core/Upfile.php?Dir=content&amp;form=userfile'+num+'&img=imgdef'+num+'\',\'_upLoad\' ,\'height=220,width=450,resizable=no,scrollbars=yes\')") />&nbsp; <a href="javascript:;" onclick="removeElement(\''+divIdName+'\');">Xóa</a></p>';

	  ni.appendChild(newdiv);

	}
	function removeElement(divNum) {

	  var vl = document.getElementById('theValue');
	  vl.value= vl.value-1;
	  var d = document.getElementById('myDiv');

	  var olddiv = document.getElementById(divNum);

	  d.removeChild(olddiv);

	}
</script>
<script type="text/javascript" src="../tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">

	// O2k7 skin
	tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",
		width : "700",
		height : "200",
		skin : "o2k7",
		plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist,autosave,visualblocks",

		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,sub,sup,link,unlink,formatselect,fontselect,fontsizeselect,forecolor,backcolor",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_buttons4 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
		theme_advanced_path : false, 
		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		

	});
				
/* Default skin */



</script>

<form style="padding:0; margin:0" action="index.php?tn=customers&kh=care_submit" method="post" name="frmAddMessage" enctype="multipart/form-data">

<?php 
	$id=$_GET['id'];
	$sql_dmll=mysql_query("select * from daumoilienlac where id='$id'");
	$rs_dmll=mysql_fetch_array($sql_dmll)
?>  
		<input type="hidden" name="kh_id" value="<?php echo $sql_dmll['id'];?>"/>
        <div class="clear" style="height:5px"></div>
        <table class="box-vang" border="0" cellpadding="0" cellspacing="0" width="100%">
          <tbody><tr>
            <td class="t-l" width="8px"></td>
            <td class="t-c"></td>
            <td class="t-r" width="8px"></td>
          </tr>
          <tr class="light">
            <td class="c-l"></td>
            <td class="c-c"><table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tbody><tr class="light">
                  <td class="title-red" colspan="2" align="left">&nbsp;Chi tiết đầu mối liên lạc <span style="float:right">Cập nhật cuối: <?php echo date('d/m/Y h:i a',$rs_dmll['update_time']);?> </span></td>
                </tr>
               
                <tr><td class="title-red1" colspan="2">Đầu mối liên lạc</td></tr>
                <tr class="light">
                  <td width="319" style="padding:10px">
         			<table>
                    
                    <tr><td>Họ tên: <strong><?php echo $rs_dmll['name'];?></strong></td></tr>
                    <tr><td>Giới tính: <strong><?php echo $rs_dmll['sex'];?></strong></td></tr>
                    <tr><td>Ngày sinh: <strong><?php echo $rs_dmll['birthday'];?></strong></td></tr>
                    <tr><td>Tình trạng hôn nhân: <strong><?php echo $rs_dmll['status'];?></strong></td></tr>
                   
                   <tr><td>Ghi chú: <strong><?php echo $rs_dmll['notes'];?></strong></td></tr>
                    </table> 
                  </td> 
                 <td width="273" style="padding:10px">
         			<table> 
                    <tr>
                    	 <?php 
							$sql_kh=mysql_query("select id,name_kh,name_com from customers where id='".$rs_dmll['khachhang_id']."'");
							$row_kh=mysql_fetch_array($sql_kh);
						?>
                    <td>Liên quan tới khách hàng: <strong><?php if($row_kh['name_kh']==""){echo $row_kh['name_com'];}else{echo $row_kh['name_kh'];}?></strong></td>
                    </tr>
                    <tr><td>Phòng ban: <strong><?php echo $rs_dmll['room'];?></strong></td></tr>
                    <tr><td>Chức vụ: <strong><?php echo $rs_dmll['chucvu'];?></strong></td></tr>
                   	<tr><td>Điện thoại cố định: <strong><?php echo $rs_dmll['telephone'];?></strong></td></tr>
                    <tr><td>Điện thoại di động: <strong><?php echo $rs_dmll['mobile'];?></strong></td></tr>
                    </table> 
                  </td> 
                </tr> 
                
                 <tr><td class="title-red1" colspan="2">Địa chỉ liên hệ</td></tr>
                <tr class="light">
                  <td style="padding:10px">
         			<table>
                    
                    <tr><td>Địa chỉ: <?php echo $rs_dmll['address'];?> </td></tr>
                    <tr><td>Quốc gia:  </td></tr>
                    <tr><td>Tỉnh thành: </td></tr>
                  
                    </table> 
                  </td> 
                 <td style="padding:10px">
         			<table>
                   
                    <tr><td>Fax: <?php echo $rs_dmll['fax'];?> </td></tr>  
                    <tr><td>Email: <?php echo $rs_dmll['email'];?> </td></tr>  
                    <tr><td>Nick chát: <?php echo $rs_dmll['nick_name'];?> </td></tr>  
                    </table> 
                  </td> 
                </tr> 
                <?php 
					$sql_nkh=mysql_query("
								select services_type_name,services_type_id  from tb_services_type where phanloai_id=15 and services_type_id='".$rs_kh['nguon_kh']."'
					
					");
						$rs_nkh=mysql_fetch_array($sql_nkh);
					$sql_lkh=mysql_query("select services_type_name,services_type_id  from tb_services_type where phanloai_id=16 and 
							services_type_id='".$rs_kh['loai_kh']."'");
							$rs_lkh=mysql_fetch_array($sql_lkh);
					$sql_lv=mysql_query("select services_type_name,services_type_id  from tb_services_type where phanloai_id=18 and services_type_id='".$rs_kh['area']."'");
						$rs_llv=mysql_fetch_array($sql_lv);
				?>
                 
                 <tr><td class="title-red1" colspan="2">Thông tin quản lý</td></tr>
                <tr class="light">
                  <td style="padding:10px">
         			<table>
                    <?php $dvql=mysql_query("select room_id,room_name from tb_room where room_id='".$rs_dmll['manager_unit']."'");
						$rs_dvql=mysql_fetch_array($dvql)
					?>
                    <tr><td>Đơn vị quản lý: <?php echo $rs_dvql['room_name'];?></td></tr>
                     <?php $nql=mysql_query("select account_id,account_name from tb_account_admin where account_id='".$rs_dmll['manager']."'");
						$rs_nql=mysql_fetch_array($nql)
					?>
                    <tr><td>Người quản lý: <?php echo $rs_nql['account_name'];?></td></tr>
                    <tr>
                    	<td>Người quản lý khác: 
                        <?php 
					  	$accont_id=explode(',',$rs_dmll['manager_other']);
						$so_account=count($accont_id)-1;
						for($p=1;$p<=$so_account;$p++)
						{
							$tong_account=$accont_id[$p-1];
						
							$sql_account=mysql_query("select account_id,account_name from tb_account_admin where account_id='$tong_account'");
							while($rs_account=mysql_fetch_array($sql_account))
							{
								echo $rs_account['account_name'].',';
							}
						}
					  ?>
                        </td>
                     </tr>                    
                    </table> 
                  </td> 
                 <td style="padding:10px">
         			<table>
                   
                    <tr>
                    	<?php $sql_nt=mysql_query("select account_id,account_name from tb_account_admin where account_id='".$rs_dmll['creater']."'");
								$row_nt=mysql_fetch_array($sql_nt);
						?>
                    	<td>Người tạo: <?php echo $row_nt['account_name'];?></td>
                     </tr>
                    <tr><td>Ngày tạo: <?php echo date('d/m/Y H:i a',$rs_dmll['creat_time']);?></td></tr>
                    <?php $sql_ncn=mysql_query("select account_id,account_name from tb_account_admin where account_id='".$rs_dmll['user_edit']."'");
								$row_ncn=mysql_fetch_array($sql_ncn);
						?>
                 	 <tr><td>Người cập nhật: <?php echo $row_ncn['account_name'];?></td></tr>
                    <tr><td>Ngày cập nhật: <?php echo date('d/m/Y H:i a',$rs_dmll['update_time']);?></td></tr>
                   
                    </table> 
                  </td> 
                </tr> 
              </tbody> </table></td>
            <td class="c-r"></td>
          </tr>
          <tr>
            <td class="b-l"></td>
            <td class="b-c"></td>
            <td class="b-r"></td>
          </tr>
        </tbody></table>
   <!--     
         <div class="break-sub" style="height:10px"></div>
        	 <table class="box-hong" cellpadding="0" cellspacing="0">
					  <tbody><tr class="light">
						<td class="text-l"></td>
						<td class="text-c">
							Lịch sử chăm sóc&nbsp; &nbsp;     						 						</td>
						<td class="text-r"></td>
					  </tr>
					</tbody></table>
					<table class="box-hong" cellpadding="0" cellspacing="0" width="100%">
					  <tbody><tr>
						<td class="t-l"></td>
						<td class="t-c"></td>
						<td class="t-r"></td>
					  </tr>
                     
					  <tr class="light">
						<td class="c-l"></td>
						<td class="c-c" valign="top">
                     
                        	
                            <table width="100%" cellspacing="0" cellpadding="0" style="  border-Top:1px solid #D2D2D2; border-Right:1px solid #D2D2D2;  border-bottom:1px solid #2C8834;  border-Left:1px solid #D2D2D2;">
<tr height="22px" bgcolor="#A1E3A1" align="center" class="SanPham01">
<td width="15%" bgcolor="#EEEEEE" style="  border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2;"><strong>
Người chăm sóc</strong></td>
<td width="15%"  bgcolor="#EEEEEE" style="  border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2; height:30px;"><strong>
Ngày chăm sóc</strong></td>
<td width="50%" bgcolor="#EEEEEE" style="  border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2;"><strong>
Nội dung</strong></td>
<td width="15%" bgcolor="#EEEEEE" style="  border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2;"><strong>
File đính kèm</strong></td>
</tr>
                        <?php 
						$sql_care=mysql_query("select * from care_kh where kh_care='$id'");
						while($rs_care=mysql_fetch_array($sql_care))
						{
						?>
                            	 

<tr  onmouseover="this.className='SanPham02hover'" onmouseout="this.className='SanPham02'" class="SanPham02">
<td style="  border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2; padding:0px 0px 0px 10px"><?php echo $rs_care['user_care'];?></td>
<td height="25" style="  border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2; padding:0px 0px 0px 10px"><?php echo date('d/m/Y - H:i a',$rs_care['time_care']);?></td>
<td style="border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2; padding:0px 0px 0px 10px">
<?php echo $rs_care['content_care'];?>
</td>
<td style="  border-bottom:1px solid #D2D2D2; border-Right:1px solid #D2D2D2; padding:0px 0px 0px 10px" align="center">
  <?php if($rs_care['file_care']!==""){?>
						 		
                        <?php 
						$arr_hinhanh=explode("~",$rs_care['file_care']);
						
						$soanh = count($arr_hinhanh);
						
						for($i=1; $i<=$soanh;$i++){
						$hinhanh = $arr_hinhanh[$i-1];
							
						?>
                       
                        <div style="margin-top:10px; margin-left:10px;">
                        
                         <table>
                            	<tr>
                            		<td>
                                    
                    			 <a href="<?php echo $hinhanh;?>"> <img src="<?php echo $hinhanh;?>" width="50" height="50"/> </a>
                       
                       		<?php 
					   			$key='upload/content/';
					   			$nameimg=ltrim($hinhanh,$key);	
					   		?>
                      		</td>	
                                    <td>
                        	<span style="padding-bottom:20px; font-size:12px;"><b> <?php echo $nameimg;?></b> </span>
                      				<br />
                       		<span style="margin-top:10px;"> <a href="<?php echo $hinhanh;?>">Xem chi tiết </a></span>
                           		 </td>
                            	</tr>
                                
                            </table>
                            </div>
                 <?php }?> 
                         
                          
                             
                            </div>
                              
                    <?php }?>  

</td>


</tr>


<?php }?>  
</table>    
                        </td>
						<td class="c-r"></td>
					  </tr>
					  <tr>
						<td class="b-l"></td>
						<td class="b-c"></td>
						<td class="b-r"></td>
					  </tr>
					</tbody></table>
         -->         
        <!--
        <div class="break-sub" style="height:10px"></div>
        <table class="box-vang" cellpadding="0" cellspacing="0" width="100%">
          <tbody><tr class="light">
            <td class="t-l"></td>
            <td class="t-c"></td>
            <td class="t-r"></td>
          </tr>
          <tr>
            <td class="c-l"></td>
            <td class="c-c" valign="top">
            	
            <table class="font_11" border="0" cellpadding="5" cellspacing="0" width="100%">
                <tbody>
               
                <tr class="light">
                  <td>
                  <strong>Care khách hàng này.
                  </strong><br>               
                  <font color="#ff6600">
                  	<font color="#008000">+ Lưu lịch sử chăm sóc khách hàng vào form dưới đây.<br>
					</font
                  ></font>
                  <p></p></td>
                </tr>
                 
               <tr valign="top">
                  <td>
                  <div style="position:relative">
                  	
                    <p style="width:845px;" align="center">
                  		<textarea name="noidung" id="txtnoidung" rows="15" cols="80" style="width: 80%"></textarea> 
                     </p>
					<script>$edit = new PAEditor('$edit','message','paeditor')</script>
                 
                  </div>
                 
                  </td>
               </tr>
                <td id="myDiv">
                    File đính kèm: (*.gif, *.jpg, *.png, .doc, .pdf &lt; &nbsp;5000Kb)
                      <?php $soanh=1;?>
							<div style="float:left; width:100%; margin-top:5px;">
                            
								<input type="hidden" id="userfile1" name="sanpham_hinhanh1"  value=""/>
                             
								<?php $soanhthem=1; if($arr_hinhanh[0]==""){$sanpham_hinhanh="../skins/images/photo.jpg";}else $sanpham_hinhanh = $arr_hinhanh[0];?>
                                 
								<img src="" width="50" id="imgdef1" name="imgdef1" height="40" style="float:left; border:#CCC 1px solid" />
								
								<input type="button" name="button3" value="Up file đính kèm" onclick="JavaScript:window.open('core/Upfile.php?Dir=content&amp;form=userfile1&img=imgdef1','_upLoad' ,'height=220,width=450,resizable=no,scrollbars=yes')") />
								
								<input type="hidden" value="<?php echo $soanhthem?>" name="hdnsoanh" id="theValue" />
								<a href="javascript:;" onclick="addElement();">Thêm file đính kèm</a>
							</div>
                            <br />
							<?php
								for($i=2; $i<=$soanh;$i++){
								$hinhanh = $arr_hinhanh[$i-1];
							?>
								<div id="my<?php echo $i;?>Div" style="float:left; width:100%; margin-top:10px;">
									<input type="hidden" id="userfile<?php echo $i;?>" name="sanpham_hinhanh<?php echo $i;?>"  value=""/>
                                  
								</div>
							<?php
								}
							?>
						   </td>
                </tr>
           
             
             <tr class="light" valign="top">
                  <td><input name="pid" id="pid" value="492083" type="hidden">
               <br>
            
               <label>
                  <input class="buttonnew" name="submit" id="submit" value="Lưu lại" type="submit">
               </label>
               	  </td>
             </tr>

            </table>
           </td>
            <td class="c-r"></td>
          </tr>
          <tr>
            <td class="b-l"></td>
            <td class="b-c"></td>
            <td class="b-r"></td>
          </tr>
        </tbody></table>
         -->
      </form>